{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=3050
  Verdict: Accepted
}
uses 
	SysUtils, Math;
 
const
	bigV:double=1e12;
	eps:double=1e-6;
 
var
	n:longint;
 
procedure tower(k,a,b,c:longint);
begin
     if k>1 then tower(k-1,a,c,b);
		 writeln(k,' ',a,' ',b);
     if k>1 then tower(k-1,c,b,a)
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
tower(n,1,3,2);
end.